import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import {getDictItems,parseDictValue,parseItem} from './api/dict.js'
import qs from 'qs'

Vue.config.productionTip = false
Vue.prototype.$qs = qs
Vue.prototype.getDictItems = getDictItems
Vue.prototype.parseDictValue = parseDictValue
Vue.prototype.parseItem = parseItem

Vue.prototype.suc = function(msg) {
	this.$message({
		message: msg,
		type: 'success'
	});
}
Vue.prototype.error = function(msg) {
	this.$message({
		type: 'error',
		message: msg,
	});
}
Vue.prototype.info = function(msg) {
	this.$message({
		type: 'info',
		message: msg,
	});
}
Vue.prototype.qs_stringify = function(o) {
	return qs.stringify(o,{allowDots:true,arrayFormat:'repeat'})
}

Vue.prototype.qsString=function(data){
	return this.$qs.stringify(data,{arrayFormat: 'repeat'})
}

Vue.directive('hasPremission', {
  bind: function (el, binding, vnode) {
	let permissionsStr=binding.value;
	let loginUser = JSON.parse(sessionStorage.getItem("loginuser"));
	let allPermissions = loginUser.menuPremit;
	let isHas = allPermissions.indexOf(permissionsStr)>=0;
	if(!isHas){
		 el.style.display = 'none';
	}
  }
})

new Vue({
	router,
	render: h => h(App)
}).$mount('#app')
